package GUI;

import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;


public class calendarInterface{

	static boolean dialogOpen =false;
	
	public static boolean getDialogOpenStatus()
	{
		return dialogOpen;
	}
	/**
	 * @wbp.parser.entryPoint
	 */
	public static void createCalendar(Display display, Composite parent,final StyledText commandLineInterface) {
		final Shell dialog = new Shell(display, SWT.DIALOG_TRIM);

		dialog.setLayout(new GridLayout(3, false));
		dialogOpen = true;
		

		final DateTime calendar = new DateTime(dialog, SWT.CALENDAR
				| SWT.BORDER);
		// final DateTime date = new DateTime (dialog, SWT.DATE |
		// SWT.SHORT);
		// final DateTime time = new DateTime (dialog, SWT.TIME |
		// SWT.SHORT);

		new Label(dialog, SWT.NONE);
		new Label(dialog, SWT.NONE);
		Button ok = new Button(dialog, SWT.PUSH);
		ok.setText("OK");
		ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
				false));
		ok.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				System.out
						.println("Calendar date selected (MM/DD/YYYY) = "
								+ (calendar.getMonth() + 1)
								+ "/"
								+ calendar.getDay()
								+ "/"
								+ calendar.getYear());
				String dueDate = (calendar.getMonth()+1) + "/" + calendar.getDay() + "/" + calendar.getYear();
				commandLineInterface.setText(commandLineInterface.getText() + "-d " + dueDate);
				// System.out.println ("Date selected (MM/YYYY) = " +
				// (date.getMonth () + 1) + "/" + date.getYear ());
				// System.out.println ("Time selected (HH:MM) = " +
				// time.getHours () + ":" + time.getMinutes ());
				dialog.close();
				dialogOpen = false;
			}
			
		});
		dialog.setDefaultButton(ok);
		dialog.pack();
		dialog.open();
		Point parentLocation = parent.getLocation();
		Point dialogSize = dialog.getSize();
		dialog.setLocation(parentLocation.x + dialogSize.x + 500,	parentLocation.y);

	}


}
